package jk.fox.config.registry.zookeeper;

import jk.fox.config.RpcConfiguration;
import jk.fox.config.registry.RegistryConfiguration;
import jk.fox.config.registry.RegistryConfigurationBuilder;

/**
 * @author cuichao
 * @Description: ZookeeperConfigurationBuilder
 * @Date: create in 2020/5/23 23:31
 */
public class ZookeeperConfigurationBuilder extends RegistryConfigurationBuilder {

    private ZookeeperConfiguration zookeeperConfig;

    public ZookeeperConfigurationBuilder(RpcConfiguration.RpcConfigBuilder rpcConfig) {
        super(rpcConfig);
        this.zookeeperConfig = new ZookeeperConfiguration();
    }


    @Override
    public RegistryConfiguration build() {
        return zookeeperConfig;
    }

    public ZookeeperConfigurationBuilder address(String address){
        zookeeperConfig.setServerAddress(address);
        return this;
    }

    public ZookeeperConfigurationBuilder maxRetires(int maxRetires){
        zookeeperConfig.setMaxRetires(maxRetires);
        return this;
    }

    public ZookeeperConfigurationBuilder retryIntervalMs(int retryIntervalMs){
        zookeeperConfig.setRetryIntervalMs(retryIntervalMs);
        return this;
    }

    public ZookeeperConfigurationBuilder connectionTimeoutMs(int connectionTimeoutMs){
        zookeeperConfig.setConnectionTimeoutMs(connectionTimeoutMs);
        return this;
    }

    public ZookeeperConfigurationBuilder sessionTimeoutMs(int sessionTimeoutMs){
        zookeeperConfig.setSessionTimeoutMs(sessionTimeoutMs);
        return this;
    }




}

